package cate.game.train.yoke.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTrain;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "英雄装上羁绊英雄 の 请求")
@OperationSetter(GDOperation.HERO_YOKE_ON)
public class YokeOnReq implements MsgInput {
    @NoteField(value = "英雄UID", detail = "要给哪一个英雄穿羁绊")
    public String masterUid;
    @NoteField(value = "英雄UID", detail = "要把哪一个英雄当成羁绊")
    public String slaveUid;
    @NoteField(value = "位置")
    public byte pos;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<Void> result = game.train.yoke.on(cc.getRole(), masterUid, slaveUid, pos);
        if (!result.ok()) {
            game.notice.message(cc.getRole(), result);
        } else {
            cc.sendNow(new YokeOnResp(masterUid, slaveUid, pos));
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTrain.HERO_YOKE_ON_REQ;
    }
}

